<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>HTTP throttling</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.http-send-stream.html">http_send_stream</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.http-build-str.html">http_build_str</a></div>
 <div class="up"><a href="ref.http.html">HTTP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.http-throttle" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">http_throttle</h1>
  <p class="verinfo">(PECL pecl_http &gt;= 0.10.0)</p><p class="refpurpose"><span class="refname">http_throttle</span> &mdash; <span class="dc-title">HTTP throttling</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.http-throttle-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>http_throttle</strong></span>
    ( <span class="methodparam"><span class="type">float</span> <code class="parameter">$sec</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$bytes</code><span class="initializer"> = 40960</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   Sets the throttle delay and send buffer size.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">此函数应与
<span class="function"><a href="function.http-send-data.html" class="function">http_send_data()</a></span>, <span class="function"><a href="function.http-send-file.html" class="function">http_send_file()</a></span>  和  <span class="function"><a href="function.http-send-stream.html" class="function">http_send_stream()</a></span> 一同使用。</span></p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">提供基本的节流机制，会放弃当前进程或线程，直至实体已被发送完毕。</span></p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    下列 SAPI 可能不能正常的工作： FastCGI.
   </p>
  </p></blockquote>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.http-throttle-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">sec</code></em></dt>

     <dd>

      <p class="para">
       seconds to sleep after each chunk sent
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">bytes</code></em></dt>

     <dd>

      <p class="para">
       the chunk size in bytes
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 


 


 <div class="refsect1 examples" id="refsect1-function.http-throttle-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4282">
    <p><strong>Example #1 A <span class="function"><strong>http_throttle()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     Send file with approximately 20 kbyte/s.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;~&nbsp;20&nbsp;kbyte/s<br />#&nbsp;http_throttle(1,&nbsp;20000);<br />#&nbsp;http_throttle(0.5,&nbsp;10000);<br /></span><span style="color: #0000BB">http_throttle</span><span style="color: #007700">(</span><span style="color: #0000BB">0.1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2000</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">http_send_file</span><span style="color: #007700">(</span><span style="color: #DD0000">'document.pdf'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>



 <div class="refsect1 seealso" id="refsect1-function.http-throttle-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.http-send-data.html" class="function" rel="rdfs-seeAlso">http_send_data()</a> - Send arbitrary data</span></li>
    <li class="member"><span class="function"><a href="function.http-send-file.html" class="function" rel="rdfs-seeAlso">http_send_file()</a> - Send file</span></li>
    <li class="member"><span class="function"><a href="function.http-send-stream.html" class="function" rel="rdfs-seeAlso">http_send_stream()</a> - Send stream</span></li>
    <li class="member">如使用 PHP 5.1.0 及以后版本中为
<a href="class.httpresponse.html" class="link">
<a href="class.httpresponse.html" class="classname">HttpResponse</a></a> 类。</li>
   </ul>
  </p>
 </div>



</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.http-send-stream.html">http_send_stream</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.http-build-str.html">http_build_str</a></div>
 <div class="up"><a href="ref.http.html">HTTP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
